﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Principal;
using System.Web;
using FoolTaskMgm.Common;
using FoolTaskMgm.IBLL;
using System.Web.Security;

namespace FoolTaskMgm.BLL
{
    public class AccountService : FoolTaskMgm.IBLL.IAccountService
    {
        public int MinPasswordLength { get { return MembershipService.MinPasswordLength; } }
        private IFormsAuthenticationService FormsService { get; set; }
        private IMembershipService MembershipService { get; set; }

        public AccountService()
        {
            if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
            if (MembershipService == null) { MembershipService = new AccountMembershipService(); }
        }

        public bool ValidateUser(string UserName, string Password)
        {
            return MembershipService.ValidateUser(UserName, Password);           
        }
        public MembershipCreateStatus CreateUser(string userName, string password, string email)
        { 
            return MembershipService.CreateUser(userName, password, email);            
        }       

        public bool ChangePassword(string userName, string oldPassword, string newPassword)
        {

            if (MembershipService.ChangePassword(userName, oldPassword, newPassword))
                {
                    return true;
                }
                else
                {
                    return false;

                }
            
        }

        public void SignIn(string userName, bool rememberMe)
        {
            FormsService.SignIn(userName, rememberMe);
        }

        public void SignOut()
        {
            FormsService.SignOut();
        }

    }
}
